addScheme

Associates the given URL scheme with the callback, so that all URL requests with the given scheme will be intercepted before they are sent out.

Each scheme can be treated by Chromium as:

Standard: the schemes in the standard format described in RFC 3986 Section 3. The syntax for standard scheme URLs must be in the following form:

    [scheme]://[username]:[password]@[host]:[port]/[path]

Note: the non-standard URLs with the standard scheme will be canonicalized to "scheme://host/path". For example, "scheme:host/path" will be canonicalized to "scheme://host/path".

Referrer: the schemes that are allowed for referrers.

Secure: the schemes that are treated with the same security rules as those applied to "https" URLs.

Local: the schemes that normal pages cannot link to or access (i.e. with the same security rules as those applied to "file" URLs). Normal pages cannot link to or access local URLs. Also, by default, local URLs can only perform XMLHttpRequest calls to the same URL (origin + path) that originated the request.

No Access: the schemes that cause pages loaded with them to not have access to pages loaded with any other URL scheme.

CORS Enabled: the schemes that can sent CORS requests.

Web Storage: the schemes that can be used by web pages to store data using local storage.

CSP Bypassing: the schemes that can bypass the Content-Security-Policy (CSP) checks.

For example, HTTPS is treated as standard, referrer, secure, CORS enabled, and web storage.

Not any scheme can be added and intercepted. The following schemes cannot be intercepted, so you will get IllegalArgumentException if you try to add them:

  • about
  • blob
  • content
  • cid
  • data
  • file
  • filesystem
  • ftp
  • javascript
  • mailto
  • quic-transport
  • tel
  • ws
  • wss
  • devtools
  • chrome
  • chrome-error
  • chrome-distiller
  • chrome-untrusted
  • chrome-guest
  • chrome-search
  • chrome-extension
  • chrome-native
  • view-source
  • externalfile
  • googlechrome

Since

7.13

Parameters

scheme

the URL scheme of a URL request to intercept

callback

the callback that will be invoked to intercept URL requests with the given scheme

Throws

when the given scheme cannot be intercepted